package com.wb.core08_常用类.String;

/**
 * @author 黄衡熙
 * @version 1.0
 */
public class Test05_正则表达式 {
    public static void main(String[] args) {
        //匹配字符只有一个a
        System.out.println("a".matches("a"));
        System.out.println("aa".matches("a"));
        System.out.println("=====================");
        //匹配字符只有3个a
        System.out.println("aaa".matches("a{3}"));
        System.out.println("aaaa".matches("a{3}"));
        System.out.println("=====================");
        //匹配字符只有3到5个a
        System.out.println("aaa".matches("a{3,5}"));
        System.out.println("aaaa".matches("a{3,5}"));
        System.out.println("aaaaa".matches("a{3,5}"));
        System.out.println("aaaaaa".matches("a{3,5}"));
        System.out.println("=====================");
        //匹配字符至少5个a
        System.out.println("aaaaaa".matches("a{5,}"));
        System.out.println("aaaaaa".matches("a{10,}"));
        System.out.println("=====================");
        //匹配字符至少出现1个a
        System.out.println("aaaaaa".matches("a{1,}"));
        System.out.println("a".matches("a+"));
        System.out.println("=====================");
        //匹配字符至少出现0或1个a
        System.out.println("".matches("a?"));
        System.out.println("a".matches("a?"));
        System.out.println("=====================");
        //匹配字符至少出现0或多个a
        System.out.println("aaaaaaaa".matches("a*"));
        System.out.println("".matches("a*"));
        System.out.println("=====================");
        //匹配指定字符串只有一个字符,且只能abc中的一个
        System.out.println("a".matches("[abc]"));
        System.out.println("abcaa".matches("[abc]{3,5}"));
    }
}